﻿#ifndef BNSPLAYERAPP_H
#define BNSPLAYERAPP_H

#include <QObject>
#include "Decoder.h"

QString timeToString(double);

class BNSPlayerApp : public QObject
{
    Q_OBJECT

    Q_PROPERTY(Decoder* decoder READ decoder CONSTANT)

    Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
public:
    explicit BNSPlayerApp(QObject *parent = nullptr);

    Q_INVOKABLE int openVideoFile(const QUrl& file);

    Decoder* decoder() const { return m_decoder; }

    bool isPlaying() const;

public slots:
    void pause();

    void play();

    void openFileFromSysDialog();

    void onUIProcessSliderChanged(double pos);

private slots:
    void onDecoderStateChanged(Decoder::DecodcState newState, QString desc);

    void onDecoderPosChanged();

signals:

    void isPlayingChanged();

private:
    Decoder* m_decoder = nullptr;
};

#endif // BNSPLAYERAPP_H
